package homework;

import javax.swing.*;
import java.awt.*;

public class p2699 {
    public static void main(String[] args) {
        //调用private 静态方法生成计算器
        p2699.makeCaculate();

    }

    private static void makeCaculate(){
        //创建容器,设置尺寸及布局管理器
        JFrame jFrame=new JFrame("计算器");
        jFrame.setSize(new Dimension(240,320));
        jFrame.setLayout(new BorderLayout());

        //创建结果和输入显示区域
        //创建数据输入组件区域
        JPanel printArea =new JPanel();
        printArea.setBackground(Color.pink);
        printArea.setSize(new Dimension(240,50));
        JPanel writeArea=new JPanel();
        writeArea.setLayout(new GridLayout(5,4));

        //添加显示组件
        JTextArea printField=new JTextArea(3,20);
        printField.setEditable(false);
        printField.setBackground(Color.pink);
        printField.setSize(new Dimension(240,50));
        printArea.add(printField);


        //添加数据输入组件
        writeArea.add(new Button("C"));
        writeArea.add(new Button("+/-"));
        writeArea.add(new Button("%"));
        writeArea.add(new Button("➗"));
        writeArea.add(new Button("7"));
        writeArea.add(new Button("8"));
        writeArea.add(new Button("9"));
        writeArea.add(new Button("x"));
        writeArea.add(new Button("4"));
        writeArea.add(new Button("5"));
        writeArea.add(new Button("6"));
        writeArea.add(new Button("-"));
        writeArea.add(new Button("1"));
        writeArea.add(new Button("2"));
        writeArea.add(new Button("3"));
        writeArea.add(new Button("+"));
        writeArea.add(new Button("0"));
        writeArea.add(new Button("."));
        writeArea.add(new Button("开方"));
        writeArea.add(new Button("="));





        //布局
        jFrame.add(printArea,BorderLayout.NORTH);
        jFrame.add(writeArea,BorderLayout.CENTER);

        //设置可见
        jFrame.setVisible(true);


    }
}
